/**
 * 项目名：化工企业安全生产信息化管理平台
 * 日期：    2020-03-01 22:19:08
 * Copyright (c) 2015- -版权所有
 */

package com.joysuch.wwyt.edu.repository;

import java.util.List;

import com.joysuch.wwyt.edu.entity.EduExamTestPaper;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;

/**
 * EduExamTestPaperDao
 *
 */
public interface EduExamTestPaperDao
        extends JpaRepository<EduExamTestPaper, Long>, QuerydslPredicateExecutor<EduExamTestPaper> {
    public Page<EduExamTestPaper> findAll(Specification<EduExamTestPaper> spec, Pageable pageable);

    public EduExamTestPaper save(EduExamTestPaper bean);

    public void delete(EduExamTestPaper bean);

    int deleteByExamId(Long examId);

    List<EduExamTestPaper> findByExamId(Long examId);

    @Query(value = "select count(*) from wwyt_edu_exam_test_paper where DELETE_FLAG='0' and TEST_PAPER_ID = ?1", nativeQuery = true)
    int countByPaperId(Long paperId);
}
